import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;

/**
 * @author zyj
 * @date 2022年05月30日 14:34
 */
public class FileReaderDemo {
    public static void main(String[] args) {
        FileReader reader = null;
        try {
             reader = new FileReader("a.txt");
             char[] ch = new char[1024];
             int length = 0;
             while ((length = reader.read(ch)) != -1){
                 System.out.println(length);
                 System.out.println(new String(ch,0,length));
             }
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }finally {
            try {
                reader.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }
}
